<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="bbs2.model.*, bbs2.dao.*, bbs2.service.*, bbs2.util.*" %>
<%@ page import="java.util.*" %>
<%@ include file="../_checkUser.jsp" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="../_header.jsp" %>  
<style>
    div.container table { width: auto; margin-bottom: 0;}
    table tr:first-child { background-color: #eee; }
    table td { padding: 0; }
    table td:nth-child(1) { min-width: 400px; }
    table td:nth-child(2) { text-align: right; }
</style>
</head>
<%
    RequestParameter param = new RequestParameter(request);
    int targetType = param.getInt("targetType", 0);
    int targetId = param.getInt("targetId", 0);
    
    ArrayList<File> list = FileDAO.select(targetType, targetId); 
%>
<script>
    function resize_parent_iframe() {
        if (window.parent) {
            var h = $("html").height();
            $('iframe.file', window.parent.document).css("height", h);
        }
    }
    $(resize_parent_iframe);
</script>
<body>
<% if (list.size() > 0) { %>
    <div class="container">

        <table class="table table-bordered table-condensed">
                <tr><td>첨부파일</td><td>파일크기</td><td></td></tr>
            <% for (File file : list) { %>
                <tr>
                    <td><%= file.getFileName() %></td>
                    <td><%= file.getFileSize() / 1024 %> kb</td>
                    <td><a class="btn btn-mini" href="/bbs2/FileDownloadServlet?id=<%= file.getId() %>">
                            다운로드</a>
                    </td>                        
                </tr>    
            <% } %>    
        </table>

    </div>
<% } %>
</body>
